// 模态框tab切换
$('#myModalLabel>li').click(function () {
    $(this).css({ 'border-bottom-color': '#00cf8c', 'color': '#00cf8c' }).siblings('li').css({ 'border-bottom-color': 'transparent', 'color': 'black' });
    $('#contentsChange>li').css('display', 'none').eq($(this).index()).css('display', 'block');
})
// 修改密码验证码
var phone;
var myCode;
// 忘记密码验证码
$('.forgetUserName>.sureBox>button').on('click', function () {
    phone = $('.forgetPhone').val();
    var data = {
        loginName: $('.forgetMyUserName').val(),
        mobile: phone,
    }
    console.log(data);
    request(`http://wkt.myhope365.com//pcUser/forgetpassword/send/code`, type = 'post', header = 1, data)
        .then((res) => {
            console.log(res);
        })
})
// 确认修改密码
$('#changePwd').on('click', function () {
    phone = $('.forgetPhone').val();
    var data = {
        loginName: $('.forgetMyUserName').val(),
        mobile: phone,
        password: $('.newPassword').val(),
        // checkNewPassword = $('.checkNewPassword').val(),
        code: $('.sureBtn').val()
    }
    console.log(data);
    if ($('.newPassword').val() == $('.checkNewPassword').val()) {
        request(`http://wkt.myhope365.com//pcUser/forgetpassword/send/code`, type = 'post', header = 4, data)
            .then((res) => {
                console.log(res);
            })
    } else {
        console.log("不一致");
    }

})
// console.log($('.ordinaryAdd>.sureBox>button'));
// 注册验证码
$('.ordinaryAdd>.sureBox>button').on('click', function () {
    // console.log($('.forgetPhone').val());
    phone = $('.addPhone').val();
    request(`http://wkt.myhope365.com//pcUser/register/send/code/${phone}`, type = 'get')
        .then((res) => {
            console.log(res);
        })
})
// 注册确认
$('#getPwd').on('click', function () {
    phone = $('.addPhone').val();
    var data = {
        loginName: $('.addId').val(),
        code: $('.addSure').val(),
        mobile: $('.addPhone').val(),
        password: $('.addPwd').val(),
        nickname: $('.addName').val(),
    }


    if ($('.addId').val() == "" || $('.addPwd').val() == "" || $('.addSure').val() == "" || $('.addPhone').val() == "" || $('.addName').val() == "") {
        if ($('.addId').val() == "") {
            $('.addIdPrompt').text("请输入账号（6-20位，非纯数字）！")
            $('.addId').css('border-color','red')
        } else {
            $('.addIdPrompt').text("")
            $('.addId').css('border-color', '#ddd')
        } if ($('.addPwd').val() == "") {
            $('.addPwdPrompt').text("请输入你的密码（6-20位，非汉字）！")
            $('.addPwd').css('border-color', 'red')
        } else {
            $('.addPwdPrompt').text("")
            $('.addPwd').css('border-color', '#ddd')
        } if ($('.addSure').val() == "") {
            $('.addSurePrompt').text("请输入你得到的验证码！")
            $('.addSure').css('border-color', 'red')
        } else {
            $('.addSurePrompt').text("")
            $('.addSure').css('border-color', '#ddd')
        } if ($('.addPhone').val() == "") {
            $('.addPhonePrompt').text("请输入你的电话号码！")
            $('.addPhone').css('border-color', 'red')
        } else {
            $('.addPhonePrompt').text("")
            $('.addPhone').css('border-color', '#ddd')
        } if ($('.addName').val() == "") {
            $('.addNamePrompt ').text("请输你的昵称！")
            $('.addName').css('border-color', 'red')
        } else {
            $('.addNamePrompt').text("")
            $('.addName').css('border-color', '#ddd')
        } if ($('.addPwd').val() != $('.addSurePwd').val()) {
            $('.addSurePwdPrompt').text("密码不一致")
            $('.addPwd').css('border-color', 'red')
            $('.addSurePwd').css('border-color', 'red')
        } else if ($('.addPwd').val() == ""){
            $('.addSurePwdPrompt').text("请确认你的密码！")
            $('.addSurePwd').css('border-color', 'red')
        } else {
            $('.addSurePwdPrompt').text("")
            $('.addPwd').css('border-color', '#ddd')
            $('.addSurePwd').css('border-color', '#ddd')
        }
    }
    else {
        $(".rightCon").css('border-color', '#ddd');
        $(".prompt").val('');
        request(`http://wkt.myhope365.com//pcUser/register`, type = 'POST', data, header = 1)
            .then((res) => {
                console.log(res);
                alert(`${res.msg}`);
            })
    }


})
// 普通登录
$('.ordinaryLogin').on('click', function () {
    var data = {
        username: $('.ordinaryUserName').val(),
        password: $('.ordinaryPassWord').val(),
        rememberMe: true,
    }
    console.log(data);
    request(`http://wkt.myhope365.com//pcUser/login`, type = 'POST', data, header = 1)
        .then((res) => {
            console.log(res);
            console.log(res.userInfo);
        })
})
// 手机号登录验证码
$('.phoneGetCode').on('click', function () {
    // console.log($('.forgetPhone').val());
    phone = $('.inputPhone').val();
    request(`http://wkt.myhope365.com//pcUser/login/send/code/${phone}`, type = 'get')
        .then((res) => {
            console.log(res);
        })
})
// 手机号登录
$('.phoneEnter').on('click', function () {
    var data = {
        mobile: $('.inputPhone').val(),
        code: $('.inputCode').val(),
        rememberMe: true,
    }
    console.log(data);
    request(`http://wkt.myhope365.com//pcUser/login/mobile`, type = 'POST', data, header = 1)
        .then((res) => {
            console.log(res.userInfo);
            // 查看当前登录用户个人信息
            // request(`http://wkt.myhope365.com//pcUser/login-user/info`, type = 'get')
            //     .then((res) => {
            //         console.log(res);
            //     })
        })
})
